/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author Carlos
 */
public class Salir extends HttpServlet {

    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Salir</title>");
        out.println("<meta content=\"text/html; charset=utf-16\">");        
        out.println("</head>");
        out.println ("<body alink=\"#000099\" bgcolor=\"#6d9fff\" link=\"#000099\" text=\"#000000\" vlink=\"#990099\">");
        // Imprimir cabecera
        HttpSession sesion=request.getSession();
        sesion.setAttribute("red", null);
        sesion.setAttribute("email", null);
        sesion.setAttribute("clave", null);
        sesion.invalidate();
        GestorPersistencia.desconectar();
        out.println ("<table cellspacing=\"5\" bgcolor=\"#2c90c9\" width = \"600\">");
        out.println ("<tr><td><img src=\"imagenes/cabecera.jpg\" align=\"bottom\" height=\"100\" width=\"80\"></td>");
        out.println ("<td align=\"left\" td valign=\"middle\"><font color=\"#f9f9f9\"><big><big><big><b>Social FP</b></font></big></big></big></td></tr>");
        out.println ("</table>");
        out.println("<table><tr>");
        out.println ("<td><img src=\"" + "imagenes/button_ok.png\"></td>");
        out.println ("<td valign=\"middle\"><big><b>&nbsp;Finalizado</b></big></td>");
        out.println ("</tr></table><p>");
        out.println ("Los cambios han sido salvados.<p>");
        out.println ("<form action=\"index.html\" method=\"get\">");
        out.println ("<input type=\"submit\" value=\"Continuar\">");
        out.println ("</form>");
        out.println("</body>");
        out.println("</html>");
        
        out.close();        
        
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
